/*
 * mp_crypt_main.cpp
 *
 *  Created on: Dec 26, 2014
 *      Author: marc
 */




/*. * mp_crypt.cpp. *
 *  Created on: Nov 9, 2014
 *      Author: marc
 */


#include <cstdio>
#include <string.h>
#include <errno.h>
#include "mp_crypt_main.hpp"
//#include <alloc.h>
/** \enum.
*  L'ensemble des erreurs que cette librairie peut remonter. */
enum mp_crypt_error {
MP_CRYPTERR_NO_ERR = 1,
MP_CRYPTERR_EMPTY_PUBLIC_STRING = 2,
MP_CRYPTERR_TOO_LONG_PUBLIC_STRING = 4
//!< MP_CRYPTERR_NO_ERRMP_CRYPTERR_EMPTY_PUBLIC_STRING = -8892,
//!< MP_CRYPTERR_EMPTY_PUBLIC_STRINGMP_CRYPTERR_TOO_LONG_PUBLIC_STRING = -8893,
//!< MP_CRYPTERR_TOO_LONG_PUBLIC_STRINGMP_CRYPTERR_LIBRARY_DEPENDANCY_FAIL = -8894
//!< MP_CRYPTERR_LIBRARY_DEPENDANCY_FAIL.
} e;
//char *MPVERSIONMAJOR = "0";
const char *MP_VERSION_MAJOR_S = "0";
const char *MP_VERSION_MINOR_S = ".08";
const char *MP_VERSION_REVISION_S = ".08";
/**. * La variable globale qui contient le code erreur. */
mp_crypt_error mp_errno;
/**
 *  *
 *   *
 *   @param P  la référence au pointeur qui contient la chaine.
 *   * @return enum mp_crypt_error. */
signed int mp_getEncrypt(char *P) {
	signed int retval = 0;
	const char *k = "Bollocs";
	if (strlen(P) == 0) {
		if (errno) {retval = errno;
	}
	else  {retval = mp_errno = MP_CRYPTERR_EMPTY_PUBLIC_STRING;
	}
	}
	else {
		if (strlen(P) >= 256) {
			if (errno) {
					retval = errno;
			}
			else  {
				retval = mp_errno = MP_CRYPTERR_TOO_LONG_PUBLIC_STRING;
			}
	}
	else {strcpy(P,k);
	}
	}
	return retval;
}
/**. * Renvoi deux versions du numéro de version de cette bibliothèque C pour Linux. * @param J pointeur vers un ensemble de pointeurs vers char. * @return int toujours 1. */int mp_getVersion(char **J) { char k[2][256];
 int indxr = 0;
 int offs = 0;
// k[0][0 + 3] = '7';
 //strcpy(k[0] + 4,"99");
 offs = 0;
 strcpy(k[0] + offs,MP_VERSION_MAJOR_S);
 indxr = offs + strlen(MP_VERSION_MAJOR_S);
 strcpy(k[0] + offs ,MP_VERSION_MINOR_S);
/*void *tm;
.void *ty;
.char *oyy;
.tm = calloc(2,sizeof(char));
.ty = calloc(256,sizeof(char));*/
//.strcpy(k[0],(char *)strncat((char *)"Version",MP_VERSION_FULL_STR,255));
//strcpy(k[0],(char *)strncat("Version"," 0.000",256));
 indxr = 0;
 strcpy(J[indxr],"Version 0.08");
 indxr = indxr + 1;
//.strcpy(J[0 + (inn * sizeof(char))],"0.06 R5899");
strcpy(J[0 + (indxr * sizeof(char))],k[0]);
/*strcpy(oyy,"0.05");
.memcpy(d *)ty,(void *)oyy,256);
.tm = ty;*/
mp_errno = MP_CRYPTERR_NO_ERR;
return mp_errno;
}
int mp_getGrog(char *P) {const char *k = "Grog returns";
strcpy(P,k);
mp_errno = MP_CRYPTERR_NO_ERR;
return mp_errno;
}
